Routing is nothing but simply your mvc url. What mean is that simply your url. for example some developers using some kinds of prefix name cls with class name and also given method name as their own idea. These kinds of things definitely end user will not understand for rectify those problem we have to use routing in mvc.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action= "Index", id = UrlParameter.Optional }
);
Description:
Routes is route collection and MapRoute is method name for routes. MapRoute have three arguments like name, url and defaults. Here name is key name and its unique.
IgnoreRoute methods used to do not allow user to invoke such kind of file .axd
routes.MapRoute(
name: "Home",
url: "",
defaults: new { controller = "Employee", action= "Index", id = UrlParameter.Optional }
);
Here when I build the application it will automatically call Index view with in Employee Controller. Please remember one thing default name unique will come last why because if you set default name as first none of your matching url will not execute.
Post your comments / questions
Recent Article
- How to hide the ID field from the Django admin?
- It is impossible to add a non nullable field without specifying a default. Django error
- ImportError: cannot import name 'url' from 'django.conf.urls' - Django Error
- How to Enable Virtualization in BIOS Security Settings in Intel Processors For Android Studio?
- Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it.
- AttributeError: 'NoneType' object has no attribute 'get_text' - Python
- ModuleNotFoundError: No module named 'openpyxl' - Python
- How to get thumbnail from vimeo video URL in Python?
Related Article